import { Button } from 'element-ui';
import { $Between, $Input, $Select, $InputNumber } from '@/.jiess';
export default function() {
	const area = this.area({
		children: this.render({
			slot: 'header',
			is: $Between,
			left: '用户信息',
			right: this.render({
				is: Button,
				size: 'small',
				type: 'primary',
				onClick: async () => {
					const values = await action.value()
					alert(JSON.stringify(values));
				}
			}, '查看用户信息')
		})
	});

	const action = area.add(
		$Input({
			$name: 'name',
			$label: '姓名',
			$rules: ['required', [2, 4]]
		}),
		$Select({
			$name: 'sex',
			$label: '性别',
			$options: [
				{ text: '男', value: 1 },
				{ text: '女', value: 2 }
			],
			$rules: ['required']
		}),
		$InputNumber({
			$name: 'age',
			$label: '年龄',
			$rules: [val => {
				if (val < 18) return '您还是未成年！！';
			}]
		})
	).done();
}